﻿/***********************************************************************************************
 * 
 * ProjectName: WMSSoft.Lib.WinKStart
 * 
 * Description: Enum and Convert Class to work with kind of link execution 
 * 
 * Created:     21.07.2012
 * 
 * Author:      matthias wagler - matthias@WMSSoft.de
 * 
 * Copyright:   Copyright 2012 by WMSSoft.de
 * 
 * Lizense:     GPLv3
 * 
 * History:     21.07.2012 - matthias wagler matthias@WMSSoft.de   -   Created
 * 
 **********************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WMSSoft.Lib.Enums
{
    /// <summary>
    /// Describe the kind of Link execution
    /// </summary>
    public enum eLinkExecutionTypes
    {
        /// <summary>
        /// The kind of execution code/program is unknown
        /// </summary>
        Unknown = 0,

        /// <summary>
        /// Link Executes a Program
        /// </summary>
        Program = 1,

        /// <summary>
        /// Link executes a code subroutine
        /// </summary>
        Code
    }

    public static class cLinkExecutionTypes
    {
        /// <summary>
        /// Returns the Enum - Value from String value
        /// </summary>
        /// <param name="Value">Given execution type</param>
        /// <returns>eLinkExecutionTypes, Unknown if the type does not exist</returns>
        public static eLinkExecutionTypes GetEnumValueFromString(string Value)
        {
            try
            {
                if (Value.ToUpper() == "PROGRAM") return eLinkExecutionTypes.Program;
                else if (Value.ToUpper() == "CODE") return eLinkExecutionTypes.Code;
                else return eLinkExecutionTypes.Unknown;
            }
            catch
            {
                return eLinkExecutionTypes.Unknown;
            }
        }

        /// <summary>
        /// Returns a string for enum - value
        /// </summary>
        /// <param name="Value">Execution Type</param>
        /// <returns>string</returns>
        public static string GetStringFromEnum(eLinkExecutionTypes Value)
        {
            try
            {
                switch (Value)
                {
                    case eLinkExecutionTypes.Code: return "Code";
                    case eLinkExecutionTypes.Program: return "Program";
                    default: return "Unknown";
                }
            }
            catch
            {
                return "Unknown";
            }
        }
    }
}
